<template>
  <div class="im-srq-topInput" style="margin-top:5px">
    <div>
      <el-button size="mini" type="primary" @click="handleQuery"
        >查询</el-button
      >
    </div>
    <div class="im-srq-topInputList">
      <ul>
      <li>
        <el-input
          size="mini"
          v-model="productCode"
          placeholder="请输入内容"
           
        ></el-input>
        <span>机型：</span>
      </li>
      <li>
        <el-input
          size="mini"
          v-model="batchNo"
          placeholder="请输入内容"
           
        ></el-input>
        <span>批次：</span>
      </li>
      <li>
        <el-input
          size="mini"
          v-model="startLotNo"
          placeholder="请输入内容"
           
        ></el-input>
        <span>起始架次：</span>
      </li>
      <li>
        <el-input
          size="mini"
          v-model="endLotNo"
          placeholder="请输入内容"
           
        ></el-input>
        <span>截止架次：</span>
      </li>
      <li>
        <el-input
          size="mini"
          v-model="qualityCode"
          placeholder="请输入内容"
           
        ></el-input>
        <span>质量编号：</span>
      </li>
      <li>
        <el-input
          size="mini"
          v-model="itemCode"
          placeholder="请输入内容"
           
        ></el-input>
        <span>图号：</span>
      </li>
      <li>
        <el-input
          size="mini"
          v-model="billNo"
          placeholder="请输入内容"
           
        ></el-input>
        <span>退货单号：</span>
      </li>
      <li>
        <el-input
          size="mini"
          v-model="returnDeliveryShop"
          placeholder="请输入内容"
           
        ></el-input>
        <span>退货移交单位：</span>
      </li>
      <li>
        <el-input
          size="mini"
          v-model="returnReceiveShop"
          placeholder="请输入内容"
           
        ></el-input>
        <span>退货接收单位：</span>
      </li>
      <li>
        <el-input
          size="mini"
          v-model="accordingNo"
          placeholder="请输入内容"
           
        ></el-input>
        <span>退货依据：</span>
      </li>
      <li>
        <el-select size="mini" v-model="returnStatus" placeholder="请选择">
          <el-option
            v-for="item in options1"
            :key="item.value"
            :label="item.label"
            :value="item.value"
          >
          </el-option>
        </el-select>
        <span>退货状态：</span>
      </li>
      <li>
        <el-input
          size="mini"
          v-model="applyEmpCode"
          placeholder="请输入内容"
           
        ></el-input>
        <span>申请人：</span>
      </li>
      <li>
        <el-date-picker
            size="mini"
            v-model="startTime"
            type="date"
            placeholder="选择日期"
            value-format="yyyy-MM-dd"
          ></el-date-picker>
        <span>申请日期 从：</span>
      </li>
      <li>
        <el-date-picker
            size="mini"
            v-model="endTime"
            type="date"
            placeholder="选择日期"
            value-format="yyyy-MM-dd"
            default-time="12:00:00"
          ></el-date-picker>
        <span>到：</span>
      </li>
    </ul>
    </div>
  </div>
</template>
<script>
import { returnQuerySearch } from "@/utils/api.js";
export default {
  name: "ImSrqTopInput",
  data() {
    return {
      options1: [
        {
          value: "1",
          label: "编辑中",
        },
        {
          value: "2",
          label: "待接收",
        },
        {
          value: "3",
          label: "待确认",
        },
        {
          value: "4",
          label: "保管待接收",
        },
        {
          value: "5",
          label: "已驳回",
        },
        {
          value: "6",
          label: "结束",
        },
        {
          value: "7",
          label: "删除",
        }
      ],
      itemCode: "",
      batchNo:"",
      billNo: "",
      returnDeliveryShop: "",
      returnReceiveShop: "",
      productCode: "",
      startLotNo: "",
      endLotNo: "",
      qualityCode: "",
      accordingNo: "",
      returnStatus: "",
      applyEmpCode: "",
      startTime: "",
      endTime: "",
      value1: "",
      pageSize:20,
      pageNumber:1,
      // indexST:'',
      // indexET:''
    };
  },
  methods:{
    getNowTime() {
      var now = new Date();
      var year = now.getFullYear(); //得到年份
      var month = now.getMonth(); //得到月份
      var date = now.getDate(); //得到日期
      month = month + 1;
      month = month.toString().padStart(2, "0");
      date = date.toString().padStart(2, "0");
      var defaultDate1 = `${year}-${month}-${date}`;
      // 减去一天的毫秒数
      now.setTime(now.getTime() + 24 * 60 * 60 * 1000);
      var month2 = now.getMonth() + 1;
      month2 = month2.toString().padStart(2, "0");
      var date2 = now.getDate()
      date2 = date2.toString().padStart(2, "0");
      // 写成yyyy-mm-dd的格式
      var yesterday = now.getFullYear() + "-" + month2 + "-" + date2;

      var defaultDate2 = yesterday;
      // this.indexST = defaultDate1
      // this.indexET = defaultDate2
      this.startTime = defaultDate1
      this.endTime = defaultDate2
      // this.$set(this.searchData, "startTime", defaultDate1);
      // this.$set(this.searchData, "endTime", defaultDate2);
    },
    handleQuery(){
      returnQuerySearch({
        searchParams: {
          itemCode: this.itemCode,
          billNo: this.billNo,
          returnDeliveryShop: this.returnDeliveryShop,
          returnReceiveShop: this.returnReceiveShop,
          productCode: this.productCode,
          batchNo: this.batchNo,
          startLotNo: this.startLotNo,
          endLotNo: this.endLotNo,
          qualityCode: this.qualityCode,
          accordingNo: this.accordingNo,
          applyEmpCode: this.applyEmpCode,
          startTime: this.startTime,
          endTime: this.endTime,
        },
        pageParameter: {
          rows: this.pageSize,
          page: this.pageNumber,
        }
      }).then((res)=>{
        // 将条件查找的数据传给Table
        this.$bus.$emit("ImSrqSearchData", res.data.responseBody);
        console.log("退货查询Search", res);
        if(res.data.retCode == 201) {
          this.$Alert({
            title: "失败",
            message: res.data.message,
            type: "error",
          });
        }
      })
    }
  },
  mounted(){
    this.$options.methods.getNowTime.bind(this)()
    this.$bus.$on('imSrqPageSize',(e)=>{
      this.pageSize = e
    returnQuerySearch({
        searchParams: {
          itemCode: this.itemCode,
          billNo: this.billNo,
          returnDeliveryShop: this.returnDeliveryShop,
          returnReceiveShop: this.returnReceiveShop,
          productCode: this.productCode,
          batchNo: this.batchNo,
          startLotNo: this.startLotNo,
          endLotNo: this.endLotNo,
          qualityCode: this.qualityCode,
          accordingNo: this.accordingNo,
          applyEmpCode: this.applyEmpCode,
          startTime: this.startTime,
          endTime: this.endTime,
        },
        pageParameter: {
          rows: this.pageSize,
          page: this.pageNumber,
        }
      }).then((res)=>{
        // 将条件查找的数据传给Table
        this.$bus.$emit("ImSrqSearchData", res.data.responseBody);
        console.log("退货查询Search", res);
      })
    })
    this.$bus.$on('imSrqPageNumber',(e)=>{
      this.pageNumber = e
      returnQuerySearch({
        searchParams: {
          itemCode: this.itemCode,
          billNo: this.billNo,
          returnDeliveryShop: this.returnDeliveryShop,
          returnReceiveShop: this.returnReceiveShop,
          productCode: this.productCode,
          batchNo: this.batchNo,
          startLotNo: this.startLotNo,
          endLotNo: this.endLotNo,
          qualityCode: this.qualityCode,
          accordingNo: this.accordingNo,
          applyEmpCode: this.applyEmpCode,
          startTime: this.startTime,
          endTime: this.endTime,
        },
        pageParameter: {
          rows: this.pageSize,
          page: this.pageNumber,
        }
      }).then((res)=>{
        // 将条件查找的数据传给Table
        this.$bus.$emit("ImSrqSearchData", res.data.responseBody);
        console.log("退货查询Search", res);
      })
    })
  }
};
</script>
<style scoped>
.el-select {
  width: 140px;
}
.el-input {
  width: 140px;
}
.im-srq-topInput {
  overflow: hidden;
}
.im-srq-topInputList {
  text-align: center;
}
.im-srq-topInput ul li {
  float: left;
  width: 23%;
  height: 30px;
  line-height: 30px;
  margin-right: 1%;
  margin-bottom: 5px;
}
.im-srq-topInput ul li span {
  float: right;
}
.im-srq-topInput ul li div {
  float: right;
}
</style>